package com.quan.amqp.listener;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.quan.common.base.constant.CommonConstant;
import com.quan.sdk.mail.service.SendMailUtils;
import com.quan.upms.entity.UpmsUser;

/**
 * RabbitMQ 主题模式
 * @author yhaoquan
 *
 */
@Component
@RabbitListener(queues = CommonConstant.MQ_TOPIC_MESSAGE_MAIL)
public class TopicMessageSendMailListener {
	
	private Logger logger = LoggerFactory.getLogger(getClass()) ;
	
	@Autowired
    private SendMailUtils mailUtils;
	
	@RabbitHandler
	public void processMessage(UpmsUser user) {
		logger.info("处理Topic队列消息==>>发送邮件>>>>>>>>");
		
		// 发送短信或邮件告知用户账号和密码
		Map<String, Object> map = new HashMap<String, Object>() ;
		map.put("account", user.getAccount());
		map.put("password", user.getPassword());
		
		//this.mailUtils.send(user.getEmail(), "全民健身后台登录账号", "mail/account", map);
		this.mailUtils.send("yhaoquan2020@163.com", "全民健身后台登录账号", "mail/account", map);
		
	}

}
